package com.maimao.api.sys;

import com.maimao.core.model.resp.Result;
import com.maimao.model.user.sys.Resources;
import com.maimao.model.user.sys.dto.DelDto;
import com.maimao.model.user.sys.dto.ResourceSearch;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author MaoLin Wang
 * @date 2020/11/29 2:00 下午
 */
@Api(value = "后台菜单管理接口")
@RequestMapping("/sys/resources")
public interface ResourcesApi {

    @ApiOperation("查询登录用户的权限")
    @GetMapping("/list-f-user")
    Result<?> getResourceList();

    @ApiOperation("资源树形数据")
    @GetMapping("/treeData")
    Result<?> treeData(Integer all);

    @ApiOperation("根据名称模糊查询资源id")
    @GetMapping("/search-name")
    Result<?> searchByNameLike(@RequestParam("key") String key);

    @ApiOperation("多条件查询父节点的子数据")
    @PostMapping("/by-parent")
    Result<?> selectChild1(
            @RequestParam("parentId") Integer parentId,
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "size", defaultValue = "5") Integer size,
            @RequestBody ResourceSearch search);

    @ApiOperation("添加资源")
    @PostMapping("/add")
    Result<?> add(@Valid @RequestBody Resources resources, BindingResult bindingResult);

    @ApiOperation("修改资源")
    @PostMapping("/update")
    Result<?> update(@Valid @RequestBody Resources resources, BindingResult bindingResult);

    @ApiOperation("批量修改状态")
    @PostMapping("/update/status")
    Result<?> updateStatusBatch(@RequestBody DelDto delDto, BindingResult bindingResult);


}
